<include file="../header" />
<body class="J_scroll_fixed">
<script type="text/javascript" src="__ROOT__/statics/js/ajaxfileupload.js"></script>
<script type="text/javascript" src="__ROOT__/statics/js/ueditor/ueditor.config.js"></script>
<script type="text/javascript" src="__ROOT__/statics/js/ueditor/ueditor.all.min.js"></script>

<script type="text/javascript">
    $(function () {

        $("button#upload").click(function(){
            //上传文件
            $.ajaxFileUpload({
                url:"{:U('customer/uploadImage')}",//处理图片脚本
                secureuri :false,
                fileElementId :'fileToUpload',//file控件id
                dataType : 'json',
                success : function (data, status){
                    $("input[name=image]").val(data);
                    $("img[name=preImage]").attr("src", data);
                },
                error: function(data, status, e){
                    alert(e);
                }
            })
        });

        $("button#send").click(function() {

            var nickname = $("input[name=nickname]").val();
            var image = $("input[name=image]").val();

            if(nickname == "") {
                alert("昵称不能为空");
                return false;
            }

            if(image == "") {
                alert("头像不能为空");
                return false;
            }

            $("form").submit();

        });

    });
</script>
<div class="wrap jj">
    <ul class="nav nav-tabs">
        <li><a href="{:U('customer/index')}">机器人列表</a></li>
        <li class="active"><a href="javascript:void(0)">编辑机器人</a></li>
    </ul>

    <div class="common-form">
        <form  id='add' method="post" class="form-horizontal J_ajaxForm" action="{:U('customer/editPost')}">
            <input type="hidden" name="id" value="{$info.customer_id}">
            <fieldset>
                <div class="control-group">
                    <label class="control-label">昵称:</label>
                    <div class="controls">
                        <input type="text" class="input" name="nickname" value="{$info.nickname}">
                    </div>
                </div>
                <div class="control-group">
                    <label class="control-label">头像预览:</label>
                    <div class="controls">
                        <img src="{$info.headimgurl}" name="preImage" style="width:224px;height:168.5px;" />
                    </div>
                </div>
                <div class="control-group">
                    <label class="control-label">上传头像:</label>
                    <div class="controls">
                        <input id="fileToUpload" type="file" name="fileToUpload" style="width:170px;">
                        <button class="btn" type="button" id="upload">上传</button>
                        <input type="hidden" name="image" value="{$info.headimgurl}" />
                    </div>
                </div>
            </fieldset>

            <div class="form-actions">
                <button id="send" type="button" class="btn btn-primary">保存</button>
                <a class="btn" href="__URL__">返回</a>
            </div>
        </form>
    </div>
</div>
<script src="__ROOT__/statics/js/common.js"></script>
</body>
</html>